<template>
  <ul data-v-59bef33a class="showProductList">
    <li data-v-59bef33a class="productItem" v-for="(item,index) in list" :key="index">
      <div data-v-59bef33a class="topImg">
        <img data-v-59bef33a :src="item.picList.slice(2,-2)" class="mainPic" />
        <div data-v-59bef33a class="joinCar">
          <strong data-v-59bef33a class="mb10" @click="increase(index)">加入购物车</strong>
          <strong data-v-59bef33a @click="detailsdata(index)">查看详情</strong>
        </div>
      </div>
      <div data-v-59bef33a class="detailBox">
        <div data-v-59bef33a class="priceWeight">
          <div data-v-59bef33a class="price">
            <em data-v-59bef33a class="iconfont iconqian"></em>
            <span data-v-59bef33a>{{item.price}}</span>
          </div>
          <span data-v-59bef33a class="weight">{{item.weight}}kg/件</span>
        </div>
        <span data-v-59bef33a class="productTitle">{{item.title}}</span>
        <div data-v-59bef33a class="scoket">
          <span data-v-59bef33a>库存</span>
          <strong data-v-59bef33a>{{item.stockNum}}</strong>
          <em data-v-59bef33a>件</em>
        </div>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  props: ["iddata"],
  data() {
    return {
      list: []
    };
  },
  created() {
    // console.log([this.iddata])
    let url = "/api/productSet/getProductListSeller";
    let data = {
      canUseAccount: "",
      currPageNo: 1,
      isPublic: "1",
      limit: 30,
      productProhibitedState: "",
      sortField: "sort_index",
      sortType: "asc",
      tagList: [this.iddata],
      title: ""
    };
    this.$axios.post(url, data).then(res => {
      this.list = res.data.data.datas;
    });
  },
  methods: {
    detailsdata(id) {
      var arr = [this.iddata,id,1];
      this.$router.push({
        path: "/details/" + arr
      });
      this.$message({
        message: "查看详情页",
        type: "warning",
        center: true
      });
    },
    increase(i) {
      this.list[i].n=1
      var obj = this.list[i];
      this.$store.commit("increasedata", obj);
      this.$message({
        message: "成功加入购物车",
        type: "success",
        center: true
      });
    }
  }
};
</script>

<style>
</style>